var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("LoadRes"),
    a = e("AD"),
    i = cc._decorator,
    r = i.ccclass,
    s = i.property,
    l = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.image_node = null),
                (t.ad_info = null),
                (t.close_btn = null),
                (t.nativeInfo = null),
                (t.closeCallBack = function () {}),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.onEnable = function () {
                this.initView(), this.addEvent();
            }),
            (t.prototype.showNativeCall = function (e) {
                this.closeCallBack = e;
            }),
            (t.prototype.initView = function () {
                var e = this;
                if (
                    ((this.nativeInfo = a.default.getInstance().getBigNativeInfo()),
                    this.nativeInfo &&
                        this.nativeInfo.adId &&
                        (this.nativeInfo.Native_icon || this.nativeInfo.Native_BigImage))
                ) {
                    a.default.getInstance().reportNative(this.nativeInfo.adId);
                    var t = this.nativeInfo.Native_BigImage;
                    t || (t = this.nativeInfo.Native_icon),
                        n.default.loadResCustom(
                            t + "?.png",
                            function (t) {
                                e.image_node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(t);
                            },
                            function () {
                                e.closeCallBack && e.closeCallBack(), (e.node.active = !1);
                            }
                        );
                } else this.closeCallBack && this.closeCallBack(), (this.node.active = !1);
                setTimeout(function () {
                    e.node && e.node.active && e.initView();
                }, 3e4);
            }),
            (t.prototype.addEvent = function () {
                this.image_node.on("click", this.nativeClick, this),
                    this.ad_info.on("click", this.nativeClick, this),
                    this.close_btn.on("click", this.closeThisNode, this);
            }),
            (t.prototype.nativeClick = function () {
                a.default.getInstance().nativeClick(this.nativeInfo.adId);
            }),
            (t.prototype.closeThisNode = function () {
                a.default.getInstance().getNativeCloseErr()
                    ? this.nativeClick()
                    : (this.closeCallBack && this.closeCallBack(), (this.node.active = !1));
            }),
            __decorate([s(cc.Node)], t.prototype, "image_node", void 0),
            __decorate([s(cc.Node)], t.prototype, "ad_info", void 0),
            __decorate([s(cc.Node)], t.prototype, "close_btn", void 0),
            __decorate([r], t)
        );
    })(cc.Component);
o.default = l;
